﻿using Mes.Domain.BoundedContext.Entities.WorkOrders;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace Mes.Infrastructure.Data.BoundedContext.EntityTypeConfigurations.WorkOrders
{
    public class WoEntityConfig : IEntityTypeConfiguration<Wo>
    {
        public void Configure(EntityTypeBuilder<Wo> builder)
        {
            builder.ToTable("wo");
            builder.HasKey(b => b.Wo_Id);
            builder.Property(b => b.Wo_Id).HasMaxLength(40).IsRequired();
            builder.Property(b => b.Wo_Desc).HasMaxLength(80).IsRequired();
            builder.Property(b => b.Process_Id).HasMaxLength(40);
            builder.Property(b => b.Bom_Ver_Id);
            builder.Property(b => b.Spec_Ver_Id).HasMaxLength(40);
            builder.Property(b => b.Item_Id).IsRequired();
            builder.Property(b => b.Start_Qty).IsRequired();
            builder.Property(b => b.Req_Qty).IsRequired();
            builder.Property(b => b.Release_Time_Utc);
            builder.Property(b => b.Release_Time_Local);
            builder.Property(b => b.Req_Finish_Time_Utc);
            builder.Property(b => b.Req_Finish_Time_Local);
            builder.Property(b => b.State_Cd).IsRequired();
            builder.Property(b => b.Wo_Priority);
            builder.Property(b => b.Cust_Info).HasMaxLength(80);
            builder.Property(b => b.Mo_Id).HasMaxLength(40);
            builder.Property(b => b.Production_Schedule_Id).HasMaxLength(80);
            builder.Property(b => b.Notes);
            builder.Property(b => b.Not_Deletable).IsRequired();
            builder.Property(b => b.Disassembly).IsRequired();
            builder.Property(b => b.May_Override_Route).IsRequired();
            builder.Property(b => b.Override_Serialization).IsRequired();
            builder.Property(b => b.Input_Wo_Id).HasMaxLength(40);
            builder.Property(b => b.Input_Oper_Id).HasMaxLength(40);
            builder.Property(b => b.Input_Seq_No);
            builder.Property(b => b.Target_Sched_Line_Id);
            builder.Property(b => b.Queue_Seq_No);
            builder.Property(b => b.Spare1).HasMaxLength(80);
            builder.Property(b => b.Spare2).HasMaxLength(80);
            builder.Property(b => b.Spare3).HasMaxLength(80);
            builder.Property(b => b.Spare4).HasMaxLength(80);
            builder.Property(b => b.Last_Edit_Comment).HasMaxLength(254);
            builder.Property(b => b.Last_Edit_By).HasMaxLength(40);
            builder.Property(b => b.Last_Edit_At).IsRequired();
            builder.Property(b => b.Mod_Id).IsRequired();
            builder.Property(b => b.Row_Id).IsRequired().UseIdentityColumn().HasIdentityOptions(startValue: 0, incrementBy: 1, minValue: 0);
        }
    }
}
